package com.gxa.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.stu.entity.dto.ManagerDto;
import com.gxa.stu.entity.vo.ManagerVo;
import com.gxa.stu.service.dtoService.ManagerDtoService;
import com.gxa.user.mapper.ManagerDtoMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class ManagerDtoServiceImpl extends ServiceImpl<ManagerDtoMapper, ManagerDto> implements ManagerDtoService {

    @Autowired
    private ManagerDtoMapper managerDtoMapper;

    @Override
    public IPage<ManagerDto> showManager(ManagerVo managerVo) {
        IPage<ManagerDto> page = new Page<>((long)managerVo.getCurrentPage(), (long)managerVo.getPageSize());
        LambdaQueryWrapper<ManagerDto> managerDtoLambdaQueryWrapper = Wrappers.lambdaQuery(ManagerDto.class);
        managerDtoLambdaQueryWrapper.like(null!=managerVo.getMgrPhone(),ManagerDto::getMgrPhone,managerVo.getMgrPhone())
                .like(null!=managerVo.getMgrName(),ManagerDto::getMgrName,managerVo.getMgrName())
                .like(null!=managerVo.getMgrNum(),ManagerDto::getMgrNum,managerVo.getMgrName())
                .like(null!=managerVo.getMgrDept(),ManagerDto::getMgrDept,managerVo.getMgrDept());
        IPage<ManagerDto> iPage = managerDtoMapper.selectPage(page, managerDtoLambdaQueryWrapper);
        return iPage;
    }
}
